package com.sds.sweng.swat.miplatform.ui.design.figures;

import org.eclipse.draw2d.Label;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;

import com.sds.sweng.swat.miplatform.ui.design.layouts.ToolbarLayoutEx;

public class MLabel extends Label {

	private ToolbarLayoutEx layout;
	private Label text;

	public static final int ALIGN_CENTER = 0;
	public static final int ALIGN_LEFT = 1;
	public static final int ALIGN_RIGHT = 2;

	public static final int VALIGN_MIDDLE = 0;
	public static final int VALIGN_TOP = 1;
	public static final int VALIGN_BOTTOM = 2;

	public MLabel() {
		layout = new ToolbarLayoutEx();
		layout.setMinorAlignment(ALIGN_LEFT);
		layout.setVerticalAlignment(VALIGN_MIDDLE);
		layout.setStretchMinorAxis(false);
		setLayoutManager(layout);

		text = new Label();
		add(text);

		setOpaque(true);
	}

	public MLabel(String s) {
		this();

		setText(s);
	}

	public void setText(String s) {
		text.setText(s);
	}

	public String getText() {
		return text.getText();
	}

	public void setAlignment(int align) {
		layout.setMinorAlignment(align);
	}

	public void setVerticalAlignment(int verticalAlignment) {
		layout.setVerticalAlignment(verticalAlignment);
	}

	public void setFont(Font font) {
		text.setFont(font);
	}

	public void setForegroundColor(Color fg) {
		super.setForegroundColor(fg);
		text.setForegroundColor(fg);
	}

}
